export function getImgSrc (richtext ,num = 3) {
	let imglist = [];
	richtext.replace(/<img [*>]*src=['"]([^'"]+)[^>]*>/g,(match,capture) => {
		imglist.push(capture)
	});
	imglist = imglist.slice(0,num)
	return imglist;
}

export function getProvince () {
	return new Promise((resolve,reject)=>{
		let historyProvince = uni.getStorageSync('historyProvince');
		if(historyProvince) {
			if((Date.now() - historyProvince.time) > 1000 * 60 * 60) {
				uni.request({
					url: 'https://restapi.amap.com/v3/ip?key=5d6b39901048d2654f4676eabbef9098',
					success: (res) => {
						uni.setStorageSync('historyProvince',{
							province: typeof(res.data.province) == 'string' ? res.data.province: '未知领域',
							time: Date.now()
						}) 
						resolve(res.data.province)
					},
					fail: (e) => {
						reject(e)
					}
				})
			} else {
				resolve(historyProvince.province)
			}
		} else {
			uni.request({
				url: 'https://restapi.amap.com/v3/ip?key=5d6b39901048d2654f4676eabbef9098',
				success: (res) => {
					uni.setStorageSync('historyProvince',{
						province: typeof(res.data.province) == 'string' ? res.data.province: '未知领域',
						time: Date.now()
					}) 
					resolve(res.data.province)
				},
				fail: (e) => {
					reject(e)
				}
			})
		}
	})
}